//
//  CXSecondCollectionViewCell.m
//  ProjectOfBStage
//
//  Created by cuixin on 15/11/13.
//  Copyright © 2015年 cuixin. All rights reserved.
//

#import "CXSecondCollectionViewCell.h"
#import <SDWebImageManager.h>
#import <UIImageView+WebCache.h>

@implementation CXSecondCollectionViewCell
-(void)dealloc{
    [_imgView release];
    [_titleLable release];
    [_teacherLable release];
    [_secondModel release];
    [super dealloc];
}
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imgView = [[UIImageView alloc] init];
        self.titleLable = [[UILabel alloc] init];
        self.teacherLable = [[UILabel alloc] init];
        
        self.imgView.layer.cornerRadius =  30;
        self.imgView.layer.masksToBounds = YES;
        
        self.titleLable.textAlignment = NSTextAlignmentCenter;
        self.teacherLable.textAlignment = NSTextAlignmentCenter;
        
        [self.titleLable setFont:[UIFont systemFontOfSize: HEIGHT_PRO(12)]];
        [self.titleLable setTextColor:[UIColor grayColor]];
        
        [self.teacherLable setFont:[UIFont systemFontOfSize:HEIGHT_PRO(12)]];
        [self.teacherLable setTextColor:[UIColor grayColor]];
        
        [self.contentView addSubview:self.imgView];
        [self.contentView addSubview:self.titleLable];
        [self.contentView addSubview:self.teacherLable];
        
        [_imgView release];
        [_titleLable release];
        [_teacherLable release];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.imgView.frame = CGRectMake(WIDTH_PRO(10), HEIGHT_PRO(20), WIDTH_PRO(60), HEIGHT_PRO(60));
    self.titleLable.frame = CGRectMake(self.imgView.frame.origin.x, self.imgView.frame.size.height + self.imgView.frame.origin.y + WIDTH_PRO(5), self.imgView.frame.size.width, HEIGHT_PRO(10));
    self.teacherLable.frame = CGRectMake(self.titleLable.frame.origin.x, self.titleLable.frame.size.height + self.titleLable.frame.origin.y + WIDTH_PRO(5), self.titleLable.frame.size.width, self.titleLable.frame.size.height);
}
-(void)setSecondModel:(CXInterSecondModel *)secondModel{
    if (_secondModel != secondModel) {
        [_secondModel release];
        _secondModel = [secondModel retain];
    }
    [self.imgView sd_setImageWithURL:[NSURL URLWithString:secondModel.avatar] placeholderImage:[UIImage imageNamed:@"wait.png"]];
    self.titleLable.text = secondModel.name;
    self.teacherLable.text = secondModel.teacher_name;
}

@end
